package com.learn.ThreadPoolLearnTwo;

import org.apache.log4j.Logger;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @author ln
 * @Description: ${todo}
 * @date 2020/12/24
 */
public class NewFixedThreadPoolTest {
    private static final Logger log=Logger.getLogger(NewFixedThreadPoolTest.class);

    public static void main(String[] args) {
        ExecutorService fixedPool = Executors.newFixedThreadPool(2, new ThreadFactory() {
            private AtomicInteger t=new AtomicInteger(1);
            @Override
            public Thread newThread(Runnable r) {
                return new Thread(r,"mypool_t"+t.getAndIncrement());
            }
        });

        fixedPool.execute(()->{
            log.debug("1");
        });

        fixedPool.execute(()->{
            log.debug("2");
        });

        fixedPool.execute(()->{
            log.debug("3");
        });
        
    }
}
